package com.geline.easyexcel.domain;

import cn.hutool.core.lang.PatternPool;
import lombok.Getter;

import java.util.regex.Pattern;

/**
 * @author: mengxin
 * @date: 2024/1/22 14:13
 */
@Getter
public enum RegexEnum {
    no("无", null),
    email("邮箱", PatternPool.EMAIL),
    mobile("手机号", PatternPool.MOBILE),
    number("整数", PatternPool.NUMBERS),
    money("小数", PatternPool.MONEY),
    birthday("生日:yyyy-mm-dd;yyyy/mm/dd;yyyy.mm.dd;yyyy年mm月dd日", PatternPool.BIRTHDAY),
    time("时间:HH:mm:ss", PatternPool.TIME),
    digital_1("1位小数", Pattern.compile("^(\\d+(?:\\.\\d)?)$")),
    digital_2("2位小数", Pattern.compile("^(\\d+(?:\\.\\d{1,2})?)$")),
    digital_3("3位小数", Pattern.compile("^(\\d+(?:\\.\\d{1,3})?)$")),
    digital_4("4位小数", Pattern.compile("^(\\d+(?:\\.\\d{1,4})?)$")),
    digital_6("6位小数", Pattern.compile("^(\\d+(?:\\.\\d{1,6})?)$")),
    digital_8("8位小数", Pattern.compile("^(\\d+(?:\\.\\d{1,8})?)$")),
    digital_10("10位小数", Pattern.compile("^(\\d+(?:\\.\\d{1,10})?)$")),
    digital_12("12位小数", Pattern.compile("^(\\d+(?:\\.\\d{1,12})?)$"));

    private String title;
    private Pattern regex;

    RegexEnum(String title, Pattern regex){
        this.title = title;
        this.regex = regex;
    }

    public Pattern getPattern(){
        return regex;
    }
}
